package com.chenfeng.back.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.chenfeng.common.controller.BaseConroller;
import com.chenfeng.common.util.ConstantFinalUtil;
import com.chenfeng.common.util.PageInfoUtil;
import com.chenfeng.investor.pojo.ABank;
import com.chenfeng.investor.pojo.AInvestor;
import com.chenfeng.investor.service.IinvestorService;



@Controller
@RequestMapping("/back/investor")
public class InvestorBackControl extends BaseConroller
{
	@Resource        
	IinvestorService investorService;
	@RequestMapping("/bankList.htm")
	public String bankList(HttpServletRequest request)
	{
		ConstantFinalUtil.LOGGER_SYSTEM.info("bankList");
		String keyword = request.getParameter("keyword");
		String status = request.getParameter("status");
		String st = request.getParameter("st");
		String ed = request.getParameter("ed");
		System.out.println("et:"+st+"sd"+ed);
		if(st == null)
		{
			st ="";
		}
		if(ed == null)
		{
			ed = "";
		}
		Date stDate = null;
		Date edDate = null;
		if(!"".equalsIgnoreCase(st)&&!"".equalsIgnoreCase(ed))
		{
			//将字符串转换成时间
			stDate = this.dateFormatUtil.parseDateTime(st);
			edDate = this.dateFormatUtil.parseDateTime(ed);		
		}
		//分页查询
		PageInfoUtil pageInfoUtil = this.proccedPageInfo(request);
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("keyword", keyword);
		map.put("status", status);
		map.put("stDate", stDate);
		map.put("edDate", edDate);
		//查询满足条件的结果
		List<ABank> bankList = this.investorService.findCondListBank(pageInfoUtil, map);
		//存储结果
		request.setAttribute("bankList", bankList);
		request.setAttribute("pageInfoUtil", pageInfoUtil);
		//存储条件
		request.setAttribute("keyword", keyword);
		request.setAttribute("status", status);
		request.setAttribute("st", st);
		request.setAttribute("ed", ed);
		ConstantFinalUtil.LOGGER_SYSTEM.info("bankList{}",bankList);
		return "/back/investor/bankList" ;
	}                 
	@RequestMapping("/investorList.htm")
	public String investorList(HttpServletRequest request)
	{		
		ConstantFinalUtil.LOGGER_SYSTEM.info("investorList");
		String keyword = request.getParameter("keyword");
		String status = request.getParameter("status");
		String coopType = request.getParameter("coopType");
		String st = request.getParameter("st");
		String ed = request.getParameter("ed");
		System.out.println("et:"+st+"sd"+ed);
		if(st == null)
		{
			st ="";
		}
		if(ed == null)
		{
			ed = "";
		}
		Date stDate = null;
		Date edDate = null;
		if(!"".equalsIgnoreCase(st)&&!"".equalsIgnoreCase(ed))
		{
			//将字符串转换成时间
			stDate = this.dateFormatUtil.parseDateTime(st);
			edDate = this.dateFormatUtil.parseDateTime(ed);		
		}
		//分页查询
		PageInfoUtil pageInfoUtil = this.proccedPageInfo(request);
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("keyword", keyword);
		map.put("status", status);
		map.put("stDate", stDate);
		map.put("edDate", edDate);
		map.put("coopType", coopType);
		//查询满足条件的结果
		List<AInvestor> investorList = this.investorService.findCondListInvestor(pageInfoUtil, map);
		//存储结果
		request.setAttribute("investorList", investorList);
		request.setAttribute("pageInfoUtil", pageInfoUtil);
		//存储条件
		request.setAttribute("keyword", keyword);
		request.setAttribute("status", status);
		request.setAttribute("coopType", coopType);
		request.setAttribute("st", st);
		request.setAttribute("ed", ed);
		ConstantFinalUtil.LOGGER_SYSTEM.info("investorList{}",investorList);
		return "/back/investor/investorList";
	}
	@RequestMapping("/updateInvestor.htm")
	public String updateInvestor()
	{
		return "/back/investor/updateInvestor";
	}
	@RequestMapping("/updateInvestorSubmit.htm")
	public String updateInvestorSubmit()
	{
		return updateInvestor();
	}
}
